<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册页面</title>
    <link rel="stylesheet" href="../style/reg.css">
    <link rel="stylesheet" href="../libs/bootstrap-5.3.0-alpha1-dist/css/bootstrap.css">
    <script src="../js/vue-2.6.12.js"></script>
    <script src="../js/axios-0.21.0.js"></script>
    <script src="../js/vue-router-3.4.9.js"></script>
    <script src="../js/qs-6.9.4.js"></script>
</head>

<body>
    <div class="header">
        <h2>新零售后端管理系统</h2>
    </div>
    <div class="containers" id="app">
        <form class="form-horizontal connet">
            <h2>注册页面</h2>
            <div class="form-group">
                <label for="inputEmail3" class="col-sm-2 control-label">账号</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="inputEmail3" placeholder="账号" v-model="user.username">
                </div>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class=" control-label">密码</label>
                <div class="col-sm-10">
                    <input type="password" class="form-control" id="inputPassword3" placeholder="密码" v-model="user.password">
                </div>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class="col-sm-3 control-label">确认密码</label>
                <div class="col-sm-10">
                    <input type="password" class="form-control" id="inputPassword3" placeholder="二次验证" v-model="user.password2">
                </div>
            </div>

            <div class="form-group">
                <label for="inputEmail3" class="col-sm-2 control-label">手机号</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="inputEmail3" placeholder="手机号" v-model="user.mobile">
                </div>
            </div>

            <div class="form-group">
                <label for="inputEmail3" class="col-sm-2 control-label">性别</label>
                <div class="col-sm-10">
                    <label class="radio-inline">
                        <input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="1" v-model="user.sex"> 男
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="0" v-model="user.sex"> 女
                    </label>
                </div>
            </div>

            <div class="form-group">
                <label for="inputEmail3" class="col-sm-2 control-label">年龄</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" id="inputEmail3" placeholder="年龄" v-model="user.age">
                </div>
            </div>
            <div class="form-group">
                <label for="inputEmail3" class="col-sm-2 control-label">描述</label>
                <div class="col-sm-10">
                    <textarea class="form-control" rows="3" v-model="user.description"></textarea>
                </div>

            </div>
            <div class="input-group">
                <input type="text" class="form-control" placeholder="请输入验证码" v-model="user.code">
                <span class="input-group-text"><img src="/shop/getCode" width="50px" height="28px" alt=""> </span>
            </div>
            <div class="form-group btns">

                <button type="button" class="btn btn-primary" @click="register">注册</button>
            </div>
            <a href="login.html" style="float: right;">注册完成、快去登录吧</a>
        </form>
    </div>
    <script>
        const app = new Vue({
            el: "#app",
            data: {
                user:{}
            },
            methods: {
             register(){
              axios.post("/shop/user/register",Qs.stringify(this.user)).then(res=>{
                  if(res.data.register){
                      alert("注册成功");
                      location.href="/shop/views/login.html";
                  }else {
                      alert("注册失败"+res.data.msg);
                     // this.user={};
                  }
              }).catch(e=>{
                  console.log(e)
                 // this.user={};
              })
             }
            }
        })
    </script>
</body>

</html>